package com.helloandroid.paso.ui.diszko;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.view.View;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Gallery;
import android.widget.Toast;

public class diszko_ui_main extends Activity {
	private WebView discoWebView;
	
	//TODO Tamas: add comments on usage of method
	//TODO Tamas: don't use toasts, use some other way, like a textview
	//TODO Tamas: layout background should be same color everywhere
	
    public void getDiszko(WebView diszko_ui_screen_webview, Gallery diszko_ui_screen_galery,
   		 final Resources res, final int url_addres, final Context c){
		
	
	/** Called when the activity is first created. */
    //@Override
    //public void onCreate(Bundle savedInstanceState) {
      //  super.onCreate(savedInstanceState);
        //setContentView(R.layout.diszko_ui_screen);
        
        //default htm page
        //discoWebView = (WebView) findViewById(R.id.diszko_ui_screen_webview);
        discoWebView = diszko_ui_screen_webview;
        discoWebView.getSettings().setJavaScriptEnabled(true);
        discoWebView.loadUrl("http://paso.hu/diszko/imtheone.htm");
        
        //gallery declarations
        //Gallery g = (Gallery) findViewById(R.id.diszko_ui_screen_galery);
        Gallery g =diszko_ui_screen_galery;
        g.setAdapter(new ImageAdapter(c));

        g.setOnItemClickListener(new OnItemClickListener() {
        	//Resources res = getResources();
        	String[] url = res.getStringArray(url_addres);
        	
			public void onItemClick(AdapterView parent, View v, int position, long id) {
            	//no result, album and other check
            	if(position <= 19){
            		discoWebView.getSettings().setJavaScriptEnabled(true);
                	discoWebView.loadUrl(url[position]);
                	//album check
                	if(position <= 8){
                		 Toast.makeText(c, "Album", Toast.LENGTH_SHORT).show();
                	//DVD check
                	}else if(position == 9){
                		Toast.makeText(c, "DVD", Toast.LENGTH_SHORT).show();
                	//other check
                	}else{
                		Toast.makeText(c, "Other", Toast.LENGTH_SHORT).show();
                	}
                	
            	}else{
            		Toast.makeText(c, "No result", Toast.LENGTH_SHORT).show();
            	}
            }
        });
    }
    

}
